package saii.integracion.utilidades;

import java.sql.SQLException;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;

import saii.business.modelo.Asignatura;
import saii.business.modelo.AsignaturaNota;
import saii.business.modelo.Profesor;
import saii.integracion.wrapper.fd2.IWrapperFD2;
import saii.integracion.wrapper.fd2.WrapperFD2;
import saii.integracion.wrapper.relacional.FuenteDatosRelacional;
import saii.integracion.wrapper.relacional.IFuenteDatosRelacional;

public class PruebaWrapperFD2 {
	
	public static void main(String[] args) {
	

			try {
				IWrapperFD2 wrapperFD2= new WrapperFD2();
				IFuenteDatosRelacional fuenteRel = wrapperFD2.getFuenteDatos();
				System.out.println(((FuenteDatosRelacional)fuenteRel).getTablas().toString());
				
			} catch (SQLException ex) {
				   System.out.println("SQLException: " + ex.getMessage());
		           System.out.println("SQLState: " + ex.getSQLState());
		           System.out.println("VendorError: " + ex.getErrorCode());
			}
			
			
			
			mostrarAsignaturas();
			
			mostrarProfesores();
			
			mostrarAsignaturaNota();
		
	}
	

	private static void mostrarAsignaturas(){
		try {
			WrapperFD2 wp2 = new WrapperFD2();
			Asignatura asig = null;
			
			ConcurrentHashMap<String, Asignatura> hma = wp2.getAsignaturasEIHM();
			
			Iterator<Entry<String, Asignatura>> it= hma.entrySet().iterator();
			

					

			Map.Entry<String,Asignatura> MapAsignatura;
			
			while (it.hasNext()) {
				
				MapAsignatura = it.next();
				
				asig = (Asignatura) MapAsignatura.getValue();

				System.out.println("---------------------------------------------------------------------------------------------------------");
				
				System.out.println(asig.toString());

			}
			
		} catch (SQLException ex) {
			   System.out.println("SQLException: " + ex.getMessage());
	           System.out.println("SQLState: " + ex.getSQLState());
	           System.out.println("VendorError: " + ex.getErrorCode());
		}
	}
	
	private static void mostrarProfesores(){
		try {
			WrapperFD2 wp2 = new WrapperFD2();
			Profesor prof = null;
			
			ConcurrentHashMap<String, Profesor> hma = wp2.getProfesoresEIHM();
			
			Iterator<Entry<String, Profesor>> it= hma.entrySet().iterator();
			

					

			Map.Entry<String,Profesor> MapProfesores;
			
			while (it.hasNext()) {
				
				MapProfesores = it.next();
				
				prof = (Profesor) MapProfesores.getValue();

				System.out.println("---------------------------------------------------------------------------------------------------------");
				
				System.out.println(prof.toString());

			}
			
		} catch (SQLException ex) {
			   System.out.println("SQLException: " + ex.getMessage());
	           System.out.println("SQLState: " + ex.getSQLState());
	           System.out.println("VendorError: " + ex.getErrorCode());
		}
	}
	
	
	private static void mostrarAsignaturaNota(){
		try {
			WrapperFD2 wp2 = new WrapperFD2();
			AsignaturaNota asigNota = null;
			
			ConcurrentHashMap<String, AsignaturaNota> hma = wp2.getAsignaturaNotaEIHM();
			
			Iterator<Entry<String, AsignaturaNota>> it= hma.entrySet().iterator();
			

					

			Map.Entry<String,AsignaturaNota> MapAsignaturaNota;
			
			while (it.hasNext()) {
				
				MapAsignaturaNota = it.next();
				
				asigNota = (AsignaturaNota) MapAsignaturaNota.getValue();

				System.out.println("---------------------------------------------------------------------------------------------------------");
				
				System.out.println(asigNota.toString());

			}
			
		} catch (SQLException ex) {
			   System.out.println("SQLException: " + ex.getMessage());
	           System.out.println("SQLState: " + ex.getSQLState());
	           System.out.println("VendorError: " + ex.getErrorCode());
		}
	}
	
	
	
	
}
